package handler

import (
	"car-trade-mgr/model"
	"github.com/gin-gonic/gin"
	"strconv"
)

func Car1Type(c *gin.Context) {
	cId, _ := strconv.Atoi(c.PostForm("c_id"))
	typeName := c.PostForm("type_name")
	carComment := c.PostForm("car_comment")
	carNum := c.PostForm("car_num")
	data := model.CarType{
		Cid:        cId,
		TypeName:   typeName,
		CarComment: carComment,
		CarNum:     carNum,
	}
	err := model.DB.Create(&data).Debug().Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "添加失败",
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
	})
	return
}
